home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PCMania 75
/
PCMania CD75_1.iso
/
pcmania
/
sbits75
/
vowel.saol
< prev
next >
Wrap
Text File
|
1998-11-29
|
1KB
|
71 lines
global {
srate 16000;
krate 400;
outchannels 1;
}
instr voice1(startmidi,startvwl,startamp) {
asig vibfreq,a,reson1,reson2,out;
ksig kinit,f1,f2,curf1,curf2,ct,oldf1,oldf2;
imports ksig vowel,amp,pitch,stop;
table vib(harm,128,1);
ivar trans;
trans = 0.1;
if (!kinit) {
kinit = 1;
vowel = startvwl;
amp = startamp;
pitch = startmidi;
}
if (stop) { turnoff; }
// kdump(pitch);
vibfreq = cpsmidi(pitch) * (oscil(vib,5,-1)*0.02 + 1)/2 + arand(5);
a = buzz(vibfreq,0,1,0.8) * amp;
if (vowel == 1) { // /i/
f1 = 260;
f2 = 2200;
}
if (vowel == 2) { // /u/
f1 = 310;
f2 = 900;
}
if (vowel == 3) { // /a/
f1 = 750;
f2 = 1100;
}
if (vowel == 4) { // /E/
f1 = 550;
f2 = 1750;
}
if (!oldf1) {
oldf1 = f1; curf1 = f1;
oldf2 = f2; curf2 = f2;
}
if (f1 != oldf1 || f2 != oldf2) {
curf1 = oldf1 + ct/trans * (f1-oldf1);
curf2 = oldf2 + ct/trans * (f2-oldf2);
ct = ct + 1/k_rate;
}
if (ct > trans) {
ct = 0;
oldf1 = f1;
oldf2 = f2;
}
reson1 = bandpass(a,curf1,curf1/5.5);
reson2 = bandpass(a,curf2,curf2/5.5);
out = (a/4 + reson1 + reson2)/2;
output(out);
}